﻿<?php
class AdminActionController extends ActionController{

    public function run() {
    
        if ($this->user->userName == 'admin') {
            $userMapper = new UserMapper();
            if( isset($this->params['delUser']) ) {
                $userMapper->dao->delEntry($this->params['delUser']);
                $articleMapper = new ArticleMapper();
                $articleMapper->dao->delEntry($this->params['delUser'],'userID');
            }
            $this->view->users =  $userMapper->getAllUsers();
        } else {
            $this->redirect('index');
        }
        $this->view->user = $this->user;
        $this->view->setRenderTemplate('admin.phtml');
    }
}
?>